# include<iostream>
# include"lss_function.cpp"
void readBxStatus2QGC(const int32_t &num);

int main() {
    std::cout << "Hello, World!" << std::endl;
    // int num = 0b11111111;
    int32_t num = 34512363;
    // printBinary(num);
    printBinaryWithSpaces(num);
    readBxStatus2QGC(num);
    // uint32_t status_temp = num & 0x0000FFFF;
    // printBinary(status_temp);
	// int bx_switch_times_remain = 100;
	// uint32_t times_temp = bx_switch_times_remain << 16;
    // printBinary(times_temp);
	// num =  status_temp | times_temp;
    // printBinary(num);

    return 0;
}
void readBxStatus2QGC(const int32_t &num)
{
    // 解析bx_status.all_status中的数据
     
    bool bx_status = num & 1;
    if(bx_status)
    {
        std::cout << "保险状态：开锁" << std ::endl;
    }else
    {
        std::cout << "保险状态：闭锁" << std ::endl;
    }
    bool dj_status = (num >> 1) & 1;
    if(dj_status)
    {
        std::cout << "打击状态：已打击" << std ::endl;
    }else
    {
        std::cout << "打击状态：未打击" << std ::endl;
    }
    int error_status = (num >> 2);
    error_status = error_status & 0b11;
    if(0 == error_status)
    {
        std::cout << "异常状态：无异常" << std ::endl;
    }else if (1 == error_status)
    {
        std::cout << "异常状态：保险板异常" << std ::endl;
    }else if (2 == error_status)
    {
        std::cout << "异常状态：点火电压不足" << std ::endl;
    }else if (3 == error_status)
    {
        std::cout << "异常状态：未定义" << std ::endl;
    }else
    {
        std::cout << "数据异常: error_status = " << error_status << std::endl;
    }
    
    std::cout << "保险次数：" << (num >> 16) << std::endl;
}

